package com.mysteel.monitor.core.response;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 *  响应结果
 * @author Administrator
 */
@Data
@Builder
public class RespResult<T> implements Serializable {

    /** 载体数据 */
    private T data ;
    /** 状态码  **/
    private String code;
    /** 消息  **/
    private String message;

    public RespResult(T data, String code, String message) {
        this.data = data;
        this.code = code;
        this.message = message;
    }

    /**
     *  操作成功
     * @param data
     * @param <T>
     * @return
     */
    public static <T> RespResult  success(T data){
        return  new RespResult<T>(data,RespResultConstant.SUCCESS,RespResultConstant.SUCCESS_MESSAGE);
    }

    /**
     *  操作失败
     * @param data
     * @param <T>
     * @return
     */
    public static <T> RespResult  fail(T data){
        return  new RespResult<T>(data,RespResultConstant.FAIL,RespResultConstant.FAIL_MESSAGE);
    }

}
